﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace WebClientTest
{
  class Program
  {
    public static string wget( WebClient client, string url )
    {
      Stream data = client.OpenRead( url );
      StreamReader reader = new StreamReader(data, Encoding.GetEncoding(950));
      string s = reader.ReadToEnd();
      data.Close();
      reader.Close();
      return s;
    }

    static void Main(string[] args)
    {
      CookieAwareWebClient client = new CookieAwareWebClient( new Uri("http://fox.hanyu.com.tw"));
      Console.WriteLine( wget(client, "http://fox.hanyu.com.tw") );
      Console.ReadLine();

      client.AddCookie( "UsersName", "");
      client.AddCookie( "UsersPwd", "");
      client.AddCookie( "UsersClass", "19");

      Console.WriteLine( wget(client, "http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=50366") );
      Console.ReadLine();
    }
  }
}
